//
//  SAAddSpendingVC.m
//  yidiantong
//
//  Created by 黄志刚 on 2021/1/11.
//

#import "SAAddSpendingVC.h"
#import "SAAddSpendingCell.h"
#import "SAStatisticalAddPayView.h"
#import "SAStatisticsExpendExpendTypeAPI.h"
#import "SAStatisticalAddPayModel.h"
#import "SAAddSpendingModel.h"
#import "SAStatisticsExpendAddAPI.h"
#import "HMSelectPeriodCalendarVC.h"
#import "HDDatePickerView.h"

@interface SAAddSpendingVC ()<UITableViewDelegate,UITableViewDataSource,HTTPAPIDelegate>

@property (nonatomic, strong) UIView *whiteView;
@property (nonatomic, strong) UILabel *dateTitleLab;
@property (nonatomic, strong) UILabel *accountTitleLab;
@property (nonatomic, strong) UILabel *dateLab;
@property (nonatomic, strong) UILabel *accountLab;
@property (nonatomic, strong) UIButton *dateBtn;
@property (nonatomic, strong) UIButton *accountBtn;

@property (nonatomic, strong) UIView *whiteView2;
@property (nonatomic, strong) UILabel *totalTitleLab;
@property (nonatomic, strong) UILabel *remarkTitleLab;
@property (nonatomic, strong) UILabel *totalLab;
@property (nonatomic, strong) UITextField *remarkTf;

@property (nonatomic, strong) UIImageView *redImageV;
@property (nonatomic, strong) UIButton *addBtn;
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) SAStatisticsExpendExpendTypeAPI *statisticsExpendExpendTypeAPI;
@property (nonatomic, strong) NSMutableArray<SAStatisticalAddPayModel *> *payMarr;
@property (nonatomic, strong) NSMutableArray<SAAddSpendingModel *> *dataMarr;
@property (nonatomic, strong) UIButton *confirmBtn;
@property (nonatomic, strong) SAStatisticsExpendAddAPI *statisticsExpendAddAPI;

@property (nonatomic, strong) UIView *moreView;
@property (nonatomic, strong) UIButton *cashBtn;
@property (nonatomic, strong) UIView *cashLine;
@property (nonatomic, strong) UIButton *cardBtn;
@property (nonatomic, strong) UIView *cardLine;
@property (nonatomic, strong) UIButton *remittanceBtn;
@property (nonatomic, strong) UIView *remittanceLine;
@property (nonatomic, strong) UIButton *weChatBtn;
@property (nonatomic, strong) UIView *weChatLine;
@property (nonatomic, strong) UIButton *alipayBtn;
@property (nonatomic, strong) UIButton *selectBtn;
@property (nonatomic, strong) UIView *tipView;


@end

@implementation SAAddSpendingVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

#pragma mark - HTTPAPIDelegate
- (void)fetchData:(id)data fromServerSuccessedWithAPI:(HTTPAPI *)api {
    if (self.statisticsExpendExpendTypeAPI == api) {
        self.payMarr = [SAStatisticalAddPayModel mj_objectArrayWithKeyValuesArray:data[@"data"]];
    }else if (self.statisticsExpendAddAPI == api) {
        !self.refreshBlock ?: self.refreshBlock();
        [self.navigationController popViewControllerAnimated:YES];
    }
}

- (void)fetchDataFromServerFailedWithError:(NSError *)error API:(HTTPAPI *)api {
 
}

#pragma mark - UITableView Delegate & DataSource
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return self.dataMarr.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    __weak typeof(self) weakSelf = self;
    SAAddSpendingCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SAAddSpendingCell" forIndexPath:indexPath];
    SAAddSpendingModel *model = self.dataMarr[indexPath.section];
    cell.model = model;
    cell.totalBlock = ^{
        [weakSelf totalPirce];
    };
    cell.typeBlock = ^{
        [weakSelf changeType:model];
    };
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return kScaleNum(35);
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    return [[UIView alloc] initWithFrame:CGRectZero];
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    return [[UIView alloc] initWithFrame:CGRectZero];
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return kScaleNum(0.01);
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 1;
}

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    return YES;
}

-(NSArray<UITableViewRowAction*>*)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewRowAction *rowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault
                                                                         title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
        [self.dataMarr removeObject:self.dataMarr[indexPath.section]];
        [self refreshData];
    }];
    rowAction.backgroundColor = kPinkColor;
    NSArray *arr = @[rowAction];
    return arr;
}

- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{
    return @"删除";
}

#pragma mark - event
-(void)clickedDateBtn {
    WeakSelf
    HDDatePickerView *pickerView = [[HDDatePickerView alloc] initWithSlectedDate:self.dateLab.text];
    [pickerView show];
    pickerView.selectDateBlock = ^(NSString *selectedDate) {
        weakSelf.dateLab.text = selectedDate;
    };
}

-(void)clickedAccountBtn {
    [self.view endEditing:YES];
    self.moreView.hidden = NO;
}

-(void)refreshData {
    self.tipView.hidden = (self.dataMarr.count > 0);
    [self.tableView reloadData];
}

-(void)clickedAddBtn {
    [self.view endEditing:YES];
    SAStatisticalAddPayView *statisticalAddPayView = [SAStatisticalAddPayView shareCornView];
    SAAddSpendingModel *model = nil;
    [statisticalAddPayView loadData:self.payMarr AndPayModel:model];
    [statisticalAddPayView showView:self];
    WeakSelf
    statisticalAddPayView.selectBlock = ^(SAStatisticalAddPayModel * _Nonnull model) {
        SAAddSpendingModel *spendingModel = [SAAddSpendingModel new];
        spendingModel.typeName = model.attrName;
        spendingModel.expendAttrId = model.expendAttrId;
        spendingModel.price = @"";
        spendingModel.remark = @"";
        [weakSelf.dataMarr addObject:spendingModel];
        [weakSelf refreshData];
    };
    statisticalAddPayView.updateMarr = ^(NSMutableArray * _Nonnull payMarr) {
        weakSelf.payMarr = payMarr;
    };
}

-(void)changeType:(SAAddSpendingModel *)spendingModel {
    [self.view endEditing:YES];
    SAStatisticalAddPayView *statisticalAddPayView = [SAStatisticalAddPayView shareCornView];
    [statisticalAddPayView loadData:self.payMarr AndPayModel:spendingModel];
    [statisticalAddPayView showView:self];
    WeakSelf
    statisticalAddPayView.editBlock = ^(SAStatisticalAddPayModel * _Nonnull model) {
        spendingModel.typeName = model.attrName;
        spendingModel.expendAttrId = model.expendAttrId;
        [weakSelf.tableView reloadData];
    };
    statisticalAddPayView.updateMarr = ^(NSMutableArray * _Nonnull payMarr) {
        weakSelf.payMarr = payMarr;
    };
}

-(void)clickedConfirmBtn {
    [self.view endEditing:YES];
    if (self.dataMarr.count == 0) {
        [Prompt popPromptViewWithMsg:@"请先录入支出信息" duration:2];
        return;
    }
    self.statisticsExpendAddAPI.remark = self.remarkTf.text;
    self.statisticsExpendAddAPI.expendType = [NSString stringWithFormat:@"%zd",self.selectBtn.tag];
    self.statisticsExpendAddAPI.expendTime = self.dateLab.text;
    double totalAmount = 0;
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    NSMutableArray *modelMarr = [NSMutableArray new];
    for (SAAddSpendingModel *model in self.dataMarr) {
        if ([model.price doubleValue] == 0) {
            [Prompt popPromptViewWithMsg:@"请先录入支出信息" duration:2];
            return;
        }
        totalAmount += [model.price doubleValue] * 100;
        NSMutableDictionary *dic = [NSMutableDictionary new];
        dic[@"amount"] = [NSString stringWithFormat:@"%0.lf",[model.price doubleValue] * 100];
        dic[@"expendAttrId"] = model.expendAttrId;
        dic[@"expendAttrName"] = model.typeName;
        dic[@"remark"] = model.remark;
        [modelMarr addObject:dic];
    }
    self.statisticsExpendAddAPI.totalAmount = [NSString stringWithFormat:@"%0.lf",totalAmount];
    dict[@"expendDetailQueries"] = modelMarr;
    self.statisticsExpendAddAPI.coverParameters = dict;
    [self.statisticsExpendAddAPI sendRequestToServerWithActivityViewAndMask:POST];
}

-(void)totalPirce {
    double totalAmount = 0;
    for (SAAddSpendingModel *model in self.dataMarr) {
        totalAmount += [model.price doubleValue];
    }
    self.totalLab.text = [NSString stringWithFormat:@"%0.2lf",totalAmount];
}

-(void)removeView {
    self.moreView.hidden = !self.moreView.isHidden;
}

-(void)clickedCashBtn:(UIButton *)sender {
    self.selectBtn.selected  = NO;
    self.selectBtn = sender;
    self.selectBtn.selected  = YES;
    _accountLab.text = sender.titleLabel.text;
    [self removeView];
}

#pragma mark - initUI
-(void)initUI {
    [self setNavigationItemBackBBIAndTitle:@"新增支出"];
    [self setBgImage:nil];
    [self addRightViews:@[self.confirmBtn]];
    self.view.backgroundColor = kBgColor;
    
    [self.view addSubview:self.whiteView];
    [self.whiteView addSubview:self.dateTitleLab];
    [self.whiteView addSubview:self.accountTitleLab];
    [self.whiteView addSubview:self.dateLab];
    [self.whiteView addSubview:self.accountLab];
    [self.whiteView addSubview:self.dateBtn];
    [self.whiteView addSubview:self.accountBtn];
    
    [self.view addSubview:self.whiteView2];
    [self.whiteView2 addSubview:self.totalTitleLab];
    [self.whiteView2 addSubview:self.remarkTitleLab];
    [self.whiteView2 addSubview:self.totalLab];
    [self.whiteView2 addSubview:self.remarkTf];
    
    [self.view addSubview:self.redImageV];
    [self.view addSubview:self.tableView];
    [self.view addSubview:self.tipView];
    [self.view addSubview:self.addBtn];
    [self.view addSubview:self.moreView];
    
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"yyyy-MM-dd"];
    NSString *timeFormatStr = [dateFormatter stringFromDate:[NSDate date]];
    _dateLab.text = timeFormatStr;
    self.statisticsExpendAddAPI.expendTime = timeFormatStr;
  
    [self.statisticsExpendExpendTypeAPI sendRequestToServerWithActivityViewAndMask:POST];
}

#pragma mark - lazy
-(UIView *)whiteView {
    if (!_whiteView) {
        _whiteView = [[UIView alloc] initWithFrame:SARectMake(0, StatusHeight, kBaseScreenWidth, 40)];
        _whiteView.backgroundColor = [UIColor whiteColor];
    }
    return _whiteView;
}

-(UILabel *)dateTitleLab {
    if (!_dateTitleLab) {
        _dateTitleLab = [[UILabel alloc] initWithFrame:SARectMake(30, 0, 35, 40)];
        _dateTitleLab.text = @"日期";
        _dateTitleLab.font = kFont(14);
        _dateTitleLab.textAlignment = NSTextAlignmentLeft;
        _dateTitleLab.textColor = kBlackColor;
    }
    return  _dateTitleLab;
}

-(UILabel *)accountTitleLab {
    if (!_accountTitleLab) {
        _accountTitleLab = [[UILabel alloc] initWithFrame:SARectMake(203, 0, 35, 40)];
        _accountTitleLab.text = @"账户";
        _accountTitleLab.font = kFont(14);
        _accountTitleLab.textAlignment = NSTextAlignmentLeft;
        _accountTitleLab.textColor = kBlackColor;
    }
    return  _accountTitleLab;
}

-(UILabel *)dateLab {
    if (!_dateLab) {
        _dateLab = [[UILabel alloc] initWithFrame:SARectMake(65, 0, 95, 40)];
        _dateLab.font = kFont(14);
        _dateLab.textAlignment = NSTextAlignmentRight;
        _dateLab.textColor = kLightgGrayColor;
    }
    return  _dateLab;
}

-(UILabel *)accountLab {
    if (!_accountLab) {
        _accountLab = [[UILabel alloc] initWithFrame:SARectMake(238, 0, 95, 40)];
        _accountLab.font = kFont(14);
        _accountLab.textAlignment = NSTextAlignmentRight;
        _accountLab.textColor = kLightgGrayColor;
        _accountLab.text  = @"现金";
    }
    return  _accountLab;
}

-(UIButton *)dateBtn {
    if (!_dateBtn) {
        _dateBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_dateBtn setImage:[UIImage imageNamed:@"shop_rightAllow"] forState:UIControlStateNormal];
        _dateBtn.frame = SARectMake(65, 0, 110, 40);
        [_dateBtn addTarget:self action:@selector(clickedDateBtn) forControlEvents:UIControlEventTouchUpInside];
        _dateBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
    }
    return _dateBtn;
}

-(UIButton *)accountBtn {
    if (!_accountBtn) {
        _accountBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_accountBtn setImage:[UIImage imageNamed:@"shop_rightAllow"] forState:UIControlStateNormal];
        _accountBtn.frame = SARectMake(238, 0, 110, 40);
        [_accountBtn addTarget:self action:@selector(clickedAccountBtn) forControlEvents:UIControlEventTouchUpInside];
        _accountBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
    }
    return _accountBtn;
}

-(UIView *)whiteView2 {
    if (!_whiteView2) {
        _whiteView2 = [[UIView alloc] initWithFrame:SARectMake(0, StatusHeight + 45, kBaseScreenWidth, 40)];
        _whiteView2.backgroundColor = [UIColor whiteColor];
    }
    return _whiteView2;
}

-(UILabel *)totalTitleLab {
    if (!_totalTitleLab) {
        _totalTitleLab = [[UILabel alloc] initWithFrame:SARectMake(30, 0, 35, 40)];
        _totalTitleLab.text = @"总额";
        _totalTitleLab.font = kFont(14);
        _totalTitleLab.textAlignment = NSTextAlignmentLeft;
        _totalTitleLab.textColor = kBlackColor;
    }
    return  _totalTitleLab;
}

-(UILabel *)remarkTitleLab {
    if (!_remarkTitleLab) {
        _remarkTitleLab = [[UILabel alloc] initWithFrame:SARectMake(203, 0, 35, 40)];
        _remarkTitleLab.text = @"备注";
        _remarkTitleLab.font = kFont(14);
        _remarkTitleLab.textAlignment = NSTextAlignmentLeft;
        _remarkTitleLab.textColor = kBlackColor;
    }
    return  _remarkTitleLab;
}

-(UILabel *)totalLab {
    if (!_totalLab) {
        _totalLab = [[UILabel alloc] initWithFrame:SARectMake(65, 0, 110, 40)];
        _totalLab.text = @"0";
        _totalLab.font = kFont(14);
        _totalLab.textAlignment = NSTextAlignmentRight;
        _totalLab.textColor = kLightgGrayColor;
    }
    return  _totalLab;
}

-(UITextField *)remarkTf {
    if (!_remarkTf) {
        _remarkTf = [[UITextField alloc] initWithFrame:SARectMake(243, 0, 105, 40)];
        _remarkTf.placeholder = @"输入备注信息";
        _remarkTf.font = kFont(14);
        _remarkTf.textAlignment = NSTextAlignmentRight;
        _remarkTf.textColor = kBlackColor;
    }
    return _remarkTf;
}

-(UIImageView *)redImageV {
    if (!_redImageV) {
        _redImageV = [[UIImageView alloc] initWithFrame:SARectMake(0, StatusHeight + 85, kBaseScreenWidth, 40)];
        _redImageV.backgroundColor = kBgColor;
        UILabel *titleLab = [[UILabel alloc] initWithFrame:SARectMake(30, 0, 80, 35)];
        titleLab.text = @"支出类别";
        titleLab.textColor = kLightgGrayColor;
        titleLab.textAlignment = NSTextAlignmentLeft;
        titleLab.font = kBFont(15);
        [_redImageV addSubview:titleLab];
        
        UILabel *titleLab2 = [[UILabel alloc] initWithFrame:SARectMake(110, 0, 120, 35)];
        titleLab2.text = @"金额";
        titleLab2.textColor = kLightgGrayColor;
        titleLab2.font = kBFont(15);
        titleLab2.textAlignment = NSTextAlignmentCenter;
        [_redImageV addSubview:titleLab2];
        
        UILabel *titleLab3 = [[UILabel alloc] initWithFrame:SARectMake(235, 0, 140, 35)];
        titleLab3.text = @"备注";
        titleLab3.textColor = kLightgGrayColor;
        titleLab3.font = kBFont(15);
        titleLab3.textAlignment = NSTextAlignmentCenter;
        [_redImageV addSubview:titleLab3];
    }
    return _redImageV;
}

-(UIButton *)addBtn {
    if (!_addBtn) {
        _addBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_addBtn setImage:[UIImage imageNamed:@"Sale_Add"] forState:UIControlStateNormal];
        _addBtn.frame = CGRectMake(kScreenWidth - kScaleNum(50), kScreenHeight - kScaleNum(95 + SafeFooterHeight), kScaleNum(50), kScaleNum(50));
        [_addBtn addTarget:self action:@selector(clickedAddBtn) forControlEvents:UIControlEventTouchUpInside];
    }
    return _addBtn;
}

-(UIButton *)confirmBtn {
    if (!_confirmBtn) {
        _confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _confirmBtn.frame = CGRectMake(0, 0, kScaleNum(60), kScaleNum(44));
        [_confirmBtn setTitle:@"完成" forState:UIControlStateNormal];
        [_confirmBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _confirmBtn.titleLabel.font = kFont(16);
        [_confirmBtn addTarget:self action:@selector(clickedConfirmBtn) forControlEvents:UIControlEventTouchUpInside];
    }
    return _confirmBtn;
}

-(UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, kScaleNum(StatusHeight + 120), kScreenWidth, kScreenHeight - kScaleNum(StatusHeight + 120)) style:UITableViewStyleGrouped];
        _tableView.backgroundColor = kLineColor;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.showsHorizontalScrollIndicator = NO;
        if (@available(iOS 11.0, *)) {
            _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        }
        _tableView.estimatedRowHeight = 0;
        _tableView.estimatedSectionHeaderHeight = 0;
        _tableView.estimatedSectionFooterHeight = 0;
        [_tableView registerClass:[SAAddSpendingCell class] forCellReuseIdentifier:@"SAAddSpendingCell"];
    }
    return _tableView;
}

-(SAStatisticsExpendExpendTypeAPI *)statisticsExpendExpendTypeAPI {
    if (!_statisticsExpendExpendTypeAPI) {
        _statisticsExpendExpendTypeAPI = [SAStatisticsExpendExpendTypeAPI apiWithDelegate:self];
    }
    return _statisticsExpendExpendTypeAPI;
}

-(SAStatisticsExpendAddAPI *)statisticsExpendAddAPI {
    if (!_statisticsExpendAddAPI) {
        _statisticsExpendAddAPI = [SAStatisticsExpendAddAPI apiWithDelegate:self];
    }
    return _statisticsExpendAddAPI;
}

-(NSMutableArray<SAAddSpendingModel *> *)dataMarr {
    if (!_dataMarr) {
        _dataMarr = [NSMutableArray array];
    }
    return _dataMarr;
}


-(UIView *)moreView {
    if (!_moreView) {
        _moreView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
        _moreView.backgroundColor = kColor(0, 0, 0, 0.3);
        _moreView.hidden = YES;
        _moreView.userInteractionEnabled = YES;
        
        UIImageView *imageV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"SAStatistics_PayType"]];
        imageV.frame = SARectMake(27, StatusHeight + 43, 321, 199);
        [_moreView addSubview:imageV];
        imageV.userInteractionEnabled = YES;
        
        [imageV addSubview:self.cashBtn];
        [imageV addSubview:self.cashLine];
        [imageV addSubview:self.cardBtn];
        [imageV addSubview:self.cardLine];
        
        [imageV addSubview:self.remittanceBtn];
        [imageV addSubview:self.remittanceLine];
        [imageV addSubview:self.weChatBtn];
        [imageV addSubview:self.weChatLine];
        
        [imageV addSubview:self.alipayBtn];
        
        self.selectBtn = self.cashBtn;
        self.selectBtn.selected = YES;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(removeView)];
        [_moreView addGestureRecognizer:tap];
    }
    return _moreView;
}

-(UIButton *)cashBtn {
    if (!_cashBtn) {
        _cashBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _cashBtn.frame = SARectMake(0, 8, 321, 37);
        [_cashBtn setTitle:@"现金" forState:UIControlStateNormal];
        _cashBtn.titleLabel.font = kFont(14);
        [_cashBtn setTitleColor:kBlackColor forState:UIControlStateNormal];
        [_cashBtn setTitleColor:kBuleColor forState:UIControlStateSelected];
        [_cashBtn addTarget:self action:@selector(clickedCashBtn:) forControlEvents:UIControlEventTouchUpInside];
        _cashBtn.tag = 1;
    }
    return _cashBtn;
}

-(UIView *)cashLine {
    if (!_cashLine) {
        _cashLine = [[UIView alloc] initWithFrame:SARectMake(0, 45, 321, 1)];
        _cashLine.backgroundColor = kLineColor;
    }
    return _cashLine;
}

-(UIButton *)cardBtn {
    if (!_cardBtn) {
        _cardBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _cardBtn.frame = SARectMake(0, 46, 321, 37);
        [_cardBtn setTitle:@"刷卡" forState:UIControlStateNormal];
        _cardBtn.titleLabel.font = kFont(14);
        [_cardBtn setTitleColor:kBlackColor forState:UIControlStateNormal];
        [_cardBtn setTitleColor:kBuleColor forState:UIControlStateSelected];
        [_cardBtn addTarget:self action:@selector(clickedCashBtn:) forControlEvents:UIControlEventTouchUpInside];
        _cardBtn.tag = 2;
    }
    return _cardBtn;
}

-(UIView *)cardLine {
    if (!_cardLine) {
        _cardLine = [[UIView alloc] initWithFrame:SARectMake(0, 83, 321, 1)];
        _cardLine.backgroundColor = kLineColor;
    }
    return _cardLine;
}

-(UIButton *)remittanceBtn {
    if (!_remittanceBtn) {
        _remittanceBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _remittanceBtn.frame = SARectMake(0, 84, 321, 37);
        [_remittanceBtn setTitle:@"汇款" forState:UIControlStateNormal];
        _remittanceBtn.titleLabel.font = kFont(14);
        [_remittanceBtn setTitleColor:kBlackColor forState:UIControlStateNormal];
        [_remittanceBtn setTitleColor:kBuleColor forState:UIControlStateSelected];
        [_remittanceBtn addTarget:self action:@selector(clickedCashBtn:) forControlEvents:UIControlEventTouchUpInside];
        _remittanceBtn.tag = 3;
    }
    return _remittanceBtn;
}

-(UIView *)remittanceLine {
    if (!_remittanceLine) {
        _remittanceLine = [[UIView alloc] initWithFrame:SARectMake(0, 121, 321, 1)];
        _remittanceLine.backgroundColor = kLineColor;
    }
    return _remittanceLine;
}

-(UIButton *)weChatBtn {
    if (!_weChatBtn) {
        _weChatBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _weChatBtn.frame = SARectMake(0, 122, 321, 37);
        [_weChatBtn setTitle:@"微信" forState:UIControlStateNormal];
        _weChatBtn.titleLabel.font = kFont(14);
        [_weChatBtn setTitleColor:kBlackColor forState:UIControlStateNormal];
        [_weChatBtn setTitleColor:kBuleColor forState:UIControlStateSelected];
        [_weChatBtn addTarget:self action:@selector(clickedCashBtn:) forControlEvents:UIControlEventTouchUpInside];
        _weChatBtn.tag = 4;
    }
    return _weChatBtn;
}

-(UIView *)weChatLine {
    if (!_weChatLine) {
        _weChatLine = [[UIView alloc] initWithFrame:SARectMake(0, 159, 321, 1)];
        _weChatLine.backgroundColor = kLineColor;
    }
    return _weChatLine;
}

-(UIButton *)alipayBtn {
    if (!_alipayBtn) {
        _alipayBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _alipayBtn.frame = SARectMake(0, 160, 321, 37);
        [_alipayBtn setTitle:@"支付宝" forState:UIControlStateNormal];
        _alipayBtn.titleLabel.font = kFont(14);
        [_alipayBtn setTitleColor:kBlackColor forState:UIControlStateNormal];
        [_alipayBtn setTitleColor:kBuleColor forState:UIControlStateSelected];
        [_alipayBtn addTarget:self action:@selector(clickedCashBtn:) forControlEvents:UIControlEventTouchUpInside];
        _alipayBtn.tag = 5;
    }
    return _alipayBtn;
}

-(UIView *)tipView {
    if (!_tipView) {
        _tipView = [[UIView alloc] initWithFrame:CGRectMake(0, kScaleNum(StatusHeight + 120), kScreenWidth, kScreenHeight - kScaleNum(StatusHeight + 120))];
        _tipView.backgroundColor = kLineColor;
        UIImageView *icon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Shop_search2"]];
        icon.frame = SARectMake(124, 147 - StatusHeight, 138, 83);
        [_tipView addSubview:icon];
        
        UILabel *titleLab = [[UILabel alloc] initWithFrame:SARectMake(0, 240 - StatusHeight, kBaseScreenWidth, 30)];
        titleLab.text = @"暂无相关信息";
        titleLab.textAlignment = NSTextAlignmentCenter;
        titleLab.textColor = kGrayColor;
        [_tipView addSubview:titleLab];
    }
    return _tipView;
}

@end
